<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:p="http://primefaces.org/ui">

    <h:form id="VoloListForm">

        <p:panel header="List of all flights in the database">

            <p:dataTable id="datalist" value="#{voloController.items}" var="item"
                         selectionMode="single" selection="#{voloController.selected}"
                         rowKey="#{item.idVOLO}"
                         paginator="true"
                         rows="10"
                         rowsPerPageTemplate="10,20,30"
                         >
              
                <p:ajax event="rowSelect"   update="viewButton"/>
                <p:ajax event="rowUnselect" update="viewButton"/>

                <p:column sortBy="#{item.idVOLO}" filterBy="#{item.idVOLO}">
                    <f:facet name="header">
                        <h:outputText value="#{myBundle.ListVoloTitle_idVOLO}"/>
                    </f:facet>
                    <h:outputText value="#{item.idVOLO}"/>
                </p:column>
                <p:column sortBy="#{item.prezzo}" filterBy="#{item.prezzo}">
                    <f:facet name="header">
                        <h:outputText value="#{myBundle.ListVoloTitle_prezzo}"/>
                    </f:facet>
                    <h:outputText value="#{item.prezzo}"/>
                </p:column>
                <p:column sortBy="#{item.data}" filterBy="#{item.data}">
                    <f:facet name="header">
                        <h:outputText value="#{myBundle.ListVoloTitle_data}"/>
                    </f:facet>
                    <h:outputText value="#{item.data}">
                        <f:convertDateTime pattern="MM/dd/yyyy" />
                    </h:outputText>
                </p:column>
                <p:column sortBy="#{item.durata}" filterBy="#{item.durata}">
                    <f:facet name="header">
                        <h:outputText value="#{myBundle.ListVoloTitle_durata}"/>
                    </f:facet>
                    <h:outputText value="#{item.durata}">
                        <f:convertDateTime pattern="HH:mm:ss" />
                    </h:outputText>
                </p:column>

                <p:column sortBy="#{item.compagnia.nome}" filterBy="#{item.compagnia.nome}">
                    <f:facet name="header">
                        <h:outputText value="#{myBundle.ListVoloTitle_compagnia}"/>
                    </f:facet>
                    <h:outputText value="#{item.compagnia.nome}"/>
                </p:column>
                <p:column sortBy="#{item.arrivo.nome}" filterBy="#{item.arrivo.nome}">
                    <f:facet name="header">
                        <h:outputText value="#{myBundle.ListVoloTitle_arrivo}"/>
                    </f:facet>
                    <h:outputText value="#{item.arrivo.nome}"/>
                </p:column>
                <p:column sortBy="#{item.arrivo.nazione}" filterBy="#{item.arrivo.nazione}">
                    <f:facet name="header">
                        <h:outputText value="Nazione"/>
                    </f:facet>
                    <h:outputText value="#{item.arrivo.nazione}"/>
                </p:column>
                <p:column sortBy="#{item.partenza.nome}" filterBy="#{item.partenza.nome}">
                    <f:facet name="header">
                        <h:outputText value="#{myBundle.ListVoloTitle_partenza}"/>
                    </f:facet>
                    <h:outputText value="#{item.partenza.nome}"/>
                </p:column>
                <p:column sortBy="#{item.partenza.nazione}" filterBy="#{item.partenza.nazione}">
                    <f:facet name="header">
                        <h:outputText value="Nazione"/>
                    </f:facet>
                    <h:outputText value="#{item.partenza.nazione}"/>
                </p:column>                <f:facet name="footer">
                    <div class="footer-section">
                        <p:commandButton id="viewButton"   icon="ui-icon-search" value="#{myBundle.View}" update=":VoloViewForm" oncomplete="VoloViewDialog.show()" disabled="#{empty voloController.selected}"/>
                    </div>
                </f:facet>

            </p:dataTable>

        </p:panel>

    </h:form>

</ui:composition>